package com.ckd.flyingtrip.utils;

import android.content.Context;
import android.util.Log;

import com.ckd.flyingtrip.javabean.UserInfoBean;
import com.google.gson.Gson;

/**
 * Created by HITMAN on 2018/6/27.
 */
public class BcUtils {
    public static Context context;
    public static PrivateShardedPreference ps;

    /*
     * 初始化
     * */
    public static void bcLoad(Context contexta) {
        context = contexta;
        ps = PrivateShardedPreference.getInstance(context);
        Log.i("load", "初始化");
    }


    public static void setUserInfo(UserInfoBean userinfo) {
        Gson gson = new Gson();
        login_Txt(ps.putString("userinfo", gson.toJson(userinfo)));
    }

    public static UserInfoBean getUserInfo() {
        Gson gson = new Gson();
        String userinfo = ps.getString("userinfo", "");
        return gson.fromJson(userinfo, UserInfoBean.class);
    }

    public static void setCityBatteryMax(String CityBatteryMax) {
        login_Txt(ps.putString("CityBatteryMax", CityBatteryMax));
    }

    public static String getCityBatteryMax() {
        return ps.getString("CityBatteryMax", "");
    }


    public static void setUid(String uid) {
        login_Txt(ps.putString("uid", uid));
    }

    public static String getUid() {
        return ps.getString("uid", "");
    }

    public static void setPhone(String Phone) {
        login_Txt(ps.putString("phone", Phone));
    }

    public static String getPhone() {
        return ps.getString("phone", "");
    }

    public static void setSignState(String SignState) {
        login_Txt(ps.putString("userSignState", SignState));
    }

    public static String getSignState() {
        return ps.getString("userSignState", "");
    }

    public static void setToken(String Token) {
        login_Txt(ps.putString("token", Token));
    }

    public static String getToken() {
        return ps.getString("token", "");
    }

    public static void setbindingElectricBicycle(String bindingElectricBicycle) {
        login_Txt(ps.putString("bindingElectricBicycle", bindingElectricBicycle));
    }

    public static String getbindingElectricBicycle() {
        return ps.getString("bindingElectricBicycle", "");
    }

    public static void setuserRent(String userRent) {
        login_Txt(ps.putString("userRent", userRent));
    }

    public static String getuserRent() {
        return ps.getString("userRent", "");
    }

    public static void setuserDeposit(String userDeposit) {
        login_Txt(ps.putString("userDeposit", userDeposit));
    }

    public static String getuserDeposit() {
        return ps.getString("userDeposit", "");
    }

    public static void setAgreementAgreed(String AgreementAgreed) {
        login_Txt(ps.putString("AgreementAgreed", AgreementAgreed));
    }

    public static String getAgreementAgreed() {
        return ps.getString("AgreementAgreed", "");
    }


    public static void login_Txt(Boolean b) {
        if (b) {
            Log.i("tag", "成功");
        } else {
            Log.i("tag", "失败");
        }
    }

    /*
     * 删除所有数据
     * */
    public static void deleteAll() {
        ps.cleanData();
        System.gc();
    }

    /*
     * 删除单个数据
     * */
    public static void deleteId(String key) {
        ps.remove(key);
    }

}
